home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-08-24 | 1.4 KB | 62 lines | [TEXT/MPS ] |
- /*
- * UControlPanel.cp (MPW 3.2)
- * Copyright ©1991 David Kreindler. All rights reserved.
- *
- * KNOWN BUGS AND SHORTCOMINGS:
- * TControlPanel::DoKeyEvent() contains hard-coded menu key equivalents; they should be stored as resources
- */
-
- #ifndef __UCONTROLPANEL__
- #include <UControlPanel.h>
- #endif
-
- void TControlPanel::DoCursor(long *) {
- Point cursLoc;
- GetMouse(&cursLoc);
- short dialogItem;
- if (dialogItem = this->FindDItem(cursLoc)) {
- Handle item;
- Rect itemRect;
- short itemType;
- this->GetDItem(dialogItem, &itemType, &item, &itemRect);
- switch (itemType) {
- case editText:
- case editText + itemDisable:
- SetCursor(iBeamCursor);
- break;
- default:
- SetCursor(crossCursor);
- }
- }
- else
- SetCursor(crossCursor);
- }
-
- void TControlPanel::DoKeyEvent(EventRecord *theEvent, long *cdevValue) {
- enum { // !!!
- kCopy = 'c', kCopy_U = 'C',
- kCut = 'x', kCut_U = 'X',
- kPaste = 'v', kPaste_U = 'V',
- kUndo = 'z', kUndo_U = 'Z'
- };
- if (theEvent->modifiers & cmdKey) { // check for a keyboard menu command
- switch (theEvent->message & charCodeMask) { // isolate the character code
- case kCopy:
- case kCopy_U:
- DoCopy(cdevValue);
- break;
- case kPaste:
- case kPaste_U:
- DoPaste(cdevValue);
- break;
- case kCut:
- case kCut_U:
- DoCut(cdevValue);
- break;
- case kUndo:
- case kUndo_U:
- DoUndo(cdevValue);
- }
- theEvent->what = nullEvent; // skip the Dialog Manager
- }
- }